<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>选课系统-选课</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="description" content="">
		<meta name="author" content="">

		<!-- Le styles -->
		<link href="resources/css/bootstrap.css" rel="stylesheet">
		<link href="resources/css/styles.css" rel="stylesheet">
		<link href="resources/css/bootstrap-responsive.css" rel="stylesheet">
		<script src="resources/js/jquery.js"></script>
		<script>
	$(function() {
		$(".button1").click(
				function() {
					var t1 = document.getElementById("form1")
							.getElementsByClassName("hidden");
					var t2 = document.getElementById("form1")
							.getElementsByClassName("checkselect");
					//var t1 = $("#form1").children("[class=hidden]");
					//var t2 = $("#form1").children("[class=checkselect]");
					for (i = 0; i < t2.length; i++) {

						if (!(t2[i].checked)) {
							t1[i].value = "0";
						} else {
							t1[i].value = "1";
						}
					}
					alert("修改选课结果成功！");
					$("#form1").submit();
				});
		$(".button2").click(function() {
			$.ajax({
				url : "confirmSelection.do",
				type : "post",
				data : {
					"uid" : $("#course_select_list").data("uid")
				},
				dataType : "json",
				success : function(json) {
					if (json == "1") {
						alert("确认选课成功！");
					}
					if (json == "0") {
						alert("确认选课失败！");
					}
					if (json == "2") {
						alert("您已经最终确认过了！");
					}
				}
			});

		});
	});
</script>
		<style type="text/css">
#main {
	width: 1000px;
	margin: 0px auto;
}

#course_select_list {
	width: 1000px;
	height: 300px;
	margin: 0px auto;
}
</style>
	</head>

	<body>
		<div class="navbar navbar-inverse navbar-fixed-top">
			<div class="navbar-inner">
				<div class="container-fluid">
					<button type="button" class="btn btn-navbar" data-toggle="collapse"
						data-target=".nav-collapse">
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</button>
					<a class="brand" href="#">选课系统</a>
					<div class="nav-collapse collapse">
						<ul class="nav">
							<li class="active">
								<a href="select.do">选课列表</a>
							</li>
						</ul>
					</div>
					<!--/.nav-collapse -->
					<form class="navbar-search pull-right" action="">
						<input class="search-query span2" type="text" placeholder="Search">
					</form>
					<ul class="nav pull-right">
						<li class="divider-vertical"></li>
						<li class="dropdown">
							<a data-toggle="dropdown" class="dropdown-toggle" href="#">${yhm}
								<b class="caret"></b> </a>
							<ul class="dropdown-menu">
								<li>
									<a href="#">Action</a>
								</li>
								<li>
									<a href="#">Another action</a>
								</li>
								<li>
									<a href="#">Something else here</a>
								</li>
								<li class="divider"></li>
								<li>
									<a href="#">Separated link</a>
								</li>
							</ul>
						</li>
					</ul>
				</div>
			</div>
		</div>
		<div id="main">
			<b>选课截止日期是7.1</b>
			<hr />
			<div id="course_select_list" data-uid="${uid}">
				<form id="form1" action="selectCourses.do" method="post">
					<table class="table table-bordered table-striped">
						<thead>
							<tr>
								<th style="width: 100px;">
									课程名
								</th>
								<th style="width: 50px;">
									已选人数
								</th>
								<th style="width: 50px;">
									人数上限
								</th>
								<th style="width: 50px">
									课程选择
								</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${selectionVOs}" var="selectionVO">
								<tr>
									<td>
										<input type="hidden" name="courseId[]"
											value=${selectionVO.courseId } />
										<a href="#">${selectionVO.courseName}</a>
									</td>
									<td>
										<a href="#">${selectionVO.num}</a>
									</td>
									<td>
										<a href="#">${selectionVO.max}</a>
									</td>
									<td>
										<a href="#"> <input class="hidden" type="hidden"
												name="checkedValue[]" /> <input type="checkbox"
												class="checkselect"
												<c:choose>
										<c:when test="${selectionVO.state=='1'}">checked="checked"</c:when>
										<c:otherwise></c:otherwise>
									</c:choose>>
										</a>
									</td>
								</tr>
							</c:forEach>

						</tbody>
					</table>
				</form>
			</div>
			<button type="button" class="button2" value=""
				style="width: 112px; height: 35px; float: right">
				<b>确定最终选课</b>
			</button>
			<hr style="float: right;" />
			<button type="button" class="button1"
				style="width: 100px; height: 35px; float: right">
				<b>提交</b>
			</button>
			<hr style="float: right;" />

		</div>
	</body>
</html>